package com.promise.jokerdream.database.entity

import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey
import kotlinx.serialization.Serializable

/**
 * 武林盟主配置实体 - 独立的完整表
 */
@Serializable
@Entity(
    tableName = "wlmz_game_config",
    foreignKeys = [
        ForeignKey(
            entity = UserConfigEntity::class,
            parentColumns = ["userId"],
            childColumns = ["userId"],
            onDelete = ForeignKey.CASCADE
        )
    ],
    indices = [Index(value = ["userId"], unique = true)]
)
data class WlmzGameConfigEntity(
    @PrimaryKey
    val userId: String,
    val enabledSetting: Boolean = false,
    val scheduledChallengeEnabled: Boolean = false,
    val registrationTime: String = "",
    val groundType: String = "GOLD" // WlmzGroundType enum
) {
    /**
     * 获取赛场ID
     * @return 赛场ID，1为黄金、2为白银、3为青铜
     */
    fun getGroundId(): Int {
        return when (groundType) {
            "GOLD" -> 1
            "SILVER" -> 2
            "BRONZE" -> 3
            else -> 1
        }
    }
}

